package com.myweather.android.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

import com.myweather.android.R;

public class SplashActivity extends AppCompatActivity {
    private static final int sleepTime = 3000;
    private SharedPreferences sharedPreferences;
    public static final String firstLogin = "firstLogin";
    private String appid = "dalin0808";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
    }

    //    private void requestJieKou() {
    //        HttpUtil.sendOkHttpRequset("http://www.jlckjz.com/back/get_init_data.php?appid=" + appid + "&type=android", new Callback() {
    //            @Override
    //            public void onFailure(Call call, IOException e) {
    //                Log.w("zcq", "net  erro ");
    //
    //
    //            }
    //
    //            @Override
    //            public void onResponse(Call call, Response response) throws IOException {
    //                String r = response.body().string();
    //                try {
    //                    JSONObject jsonObject = new JSONObject(r);
    //
    //                    String rt_code = jsonObject.getString("rt_code");
    //                    if ("200".equals(rt_code)) {//请求成功
    //                        //解析base64
    //                        String data = jsonObject.getString("data");
    //                        byte[] decode = Base64.decode(data, Base64.DEFAULT);
    //                        String decodeStr = new String(decode);
    //                        JSONObject j = new JSONObject(decodeStr);
    //                        String show_url = j.getString("show_url");//跳转1表示跳转，0表示不跳转
    //                        String url = j.getString("url");//h5页面
    //
    //                        if ("1".equals(show_url)) {
    //                            startActivity(new Intent(SplashActivity.this, WebMJActivity.class).putExtra("mjurl", url));
    //                            finish();
    //                        } else {
    //                            startActivity(new Intent(SplashActivity.this, MainActivity.class));
    //
    //                            finish();
    //                        }
    //
    //
    //                    }
    //                } catch (Exception e) {
    //                    e.printStackTrace();
    //                }
    //
    //            }
    //        });
    //
    //    }

    @Override
    protected void onResume() {
        super.onResume();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                //                requestJieKou();
                go();
            }
        }, sleepTime);
    }

    private void go() {
        //        if (sharedPreferences.getBoolean(firstLogin, true)) {
        //            sharedPreferences.edit().putBoolean(firstLogin, false).commit();
        //            startActivity(new Intent(this, GuideActivity.class));
        //        } else {
        //        }

        startActivity(new Intent(this, MainActivity.class));

        finish();

    }


}
